<template>
	<view>
		<view>
			<scroll-view class=' bg-white' scroll-y style='height:100vh'>
				<view class='margin-top padding'>
					<form class="margin-top margin">
						<text class="text-gray margin-top margin-bottom">我们致力于做最好的驾驶员招聘平台，为提高信息的真实有效，感谢您的参与。</text>
						<view class="cu-form-group solid-bottom">
							<view class="title">
								<text class='text-red'>*</text>反馈类型 :
							</view>
							<!--<input name="input" placeholder="请选择类型" v-model="selected.type" @click="openPopup=true" /> -->
							<picker :range="types" range-key='type' @change="typeChange">
								<view class="picker">
									{{selectType}}
								</view>
							</picker>
							<!-- <input hidden value="{{reportType}}" name='reportType' />
			               <input hidden value='{{reportSourceCode}}' name='reportSourceCode' />
			               <input hidden value="{{reportInfoID}}" name='reportInfoID' /> 
			               -->
						</view>

						<view class="cu-form-group" style='border-top:none;'>
							<textarea class="solid-blue bg-gray" style="height: 200px;padding:5px;" maxlength="-1" placeholder="情况说明" v-model="report.reportReason"></textarea>
						</view>
						<button @click.stop="addReport" class="cu-btn block bg-green margin-tb-sm lg margin">提 交</button>
					</form>
				</view>
				<!--  -->
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				types: [],
				openPopup: false,
				selected: {
					id: '',
					reportType: '',
				},
				selectType: '请选择反馈类型',
				report: {
					reportType: '',
					reportReason: '',
					reportInfoID: '',
					reportSourceCode: 0
				},
			};
		},
		onLoad: function(option) {
			if (option.id) {
				this.report.reportInfoID = option.id;
			}
			this.getTypes();
		},
		methods: {
			typeChange(e) {
				let index = e.detail.value;
				this.selectType = this.types[index].type;
				this.report.reportType = this.types[index].type;
			},
			addReport() {
				uni.showLoading({
					title: '提交中...',
					mask: true
				})
				let _this = this;
				this.baseRequest('api/report/', 'POST', this.report, (res) => {
					uni.hideLoading();
					setTimeout(() => {
						uni.showToast({
						  title: '反馈成功'
						});
						setTimeout(() => {
						  uni.navigateBack({
						  	
						  })
						}, 1000)
					}, 0);
				});
			},
			getTypes() {
				let d = uni.getStorageSync("types");
				if (d) {
					this.types = d;
					return;
				}
				let _this = this;
				this.baseRequest('api/report/type', 'GET', {}, (res) => {
					_this.types = res ? res : [];
					uni.setStorageSync('types', res);
				});
			},

		}
	}
</script>